#include<bits/stdc++.h>
using namespace std;

typedef long double ld;
const int N = 1e5+5;
int d[N], v[N], a[N], p[N];
ld terv;

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t, n, m, L, V;
    cin >> t;
    while (t--){
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; ++i) cin >> d[i] >> v[i] >> a[i];
        for (int i = 1; i <= m; ++i) cin >> p[i];

        int cnt = 0;
        for (int i = 1; i <= n; ++i){
            if (a[i] != 0 && d[i] <= p[m]){
                terv = sqrt(v[i]*v[i] + 2*a[i]*(p[m]-d[i]));
                if (terv > V) cnt += 1;
            }else if (v[i] > V && d[i] <= p[m]) cnt += 1;
        }
        cout << cnt << " " << (cnt == 0 ? m : m-1) << endl;
    }
    return 0;
}
